﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;

namespace LogWatcherRSS
{
    public partial class log_watch_rss : ServiceBase
    {
        bool m_ToDebug = false;
        string m_DebugFileName = "";

        string m_RSSFeedsFolder = "";                //where to put RSS feed files

        //keep a list of Event Logs to monitor
        ArrayList m_EventLogsToMonitor = new ArrayList();
        //for example, Application and System

        public log_watch_rss()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            //load settings:
            m_ToDebug = LogWatcherSettings.ToDebug();
            m_DebugFileName = LogWatcherSettings.DebugFile();
            m_RSSFeedsFolder = LogWatcherSettings.RssFeedsOutputFoler();

            //first - load list of event logs to monitor:
            string[] eventLogList = LogWatcherSettings.Filter_LogName().Split(',');
            if (m_ToDebug)
            {
                AddDebugMessage("LogWatcher_RSS monitors logs {" + LogWatcherSettings.Filter_LogName() + "}");
            }

            //for each Event Log - create instances of :
            for (int i = 0; i < eventLogList.Length; i++)
            {
                string logName = eventLogList[i];
                //one instance of EventLogRSS per log:
                EventLogRSS eventLog = new EventLogRSS(logName, m_ToDebug, m_DebugFileName, m_RSSFeedsFolder, LogWatcherSettings.Filter_LogSource(), 
                                    LogWatcherSettings.Filter_LogEvent(), LogWatcherSettings.HowManyRecordsPull());
                m_EventLogsToMonitor.Add(eventLog);
            }
        }

        protected override void OnStop()
        {
        }

        private void AddDebugMessage(string message)
        { 
        
        }
    }
}
